
//显示一个消息，会在2秒钟后自动消失
$.toast = function (msg, duration, extraclass) {
  var $toast = $('<div class="modal toast ' + (extraclass || '') + '">' + msg + '</div>').appendTo(document.body);
  $.openModal($toast);
  setTimeout(function () {
    $.closeModal($toast);
  }, duration || 2000);
};
$.openModal = function (modal, cb) {
  modal = $(modal);
  var isModal = modal.hasClass('modal');
  if (isModal) {
    modal.show();
  }
  setTimeout(function () {
    modal.removeClass('modal-out').addClass('modal-in');
  }, 100);
  return true;
};
$.closeModal = function (modal) {
  modal = $(modal || '.modal-in');
  if (typeof modal !== 'undefined' && modal.length === 0) {
    return;
  }

  modal.removeClass('modal-in').addClass('modal-out');

  setTimeout(function () {
    modal.remove();
  }, 400);

  return true;
};
